<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>订单列表</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="/${BasePath}/static/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="/${BasePath}/static/css/public.css" media="all" type="text/css">
	<style>
		.layui-table-cell{
			height:50px;
			line-height:50px
		}
	</style>
</head>
<body class="childrenBody">
<form class="layui-form" lay-filter="example">
    <blockquote class="layui-elem-quote quoteBox">
            <div class="layui-inline">
				<a class="layui-btn layui-btn-normal refresh">刷新</a>
			</div>
	</blockquote> 
	<table id="gitftList" lay-filter="gitftList"></table>
</form>

	<!--操作-->
	<script type="text/html" id="giftListBar">
		<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
		<a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">删除</a>
	</script>
	
	<!--支付状态-->
	<script type="text/html" id="payState">
		{{#  if(d.payState == "1"){ }}
		<span class="layui-red">已支付</span>
		{{#  } else { }}
			未支付
		{{#  }}}
	</script>
	
<script src="/${BasePath}/static/layui/layui.js" charset="utf-8" type="text/javascript"></script>
<script type="text/javascript" src="/${BasePath}/static/js/common/jquery-2.1.0.min.js"></script>
<script type="text/javascript" src="/${BasePath}/static/js/common/datatable_common.js"></script>
<script type="text/javascript">
layui.use(['form','layer','laydate','table','laytpl'],function(){
    var form = layui.form,
        layer = parent.layer === undefined ? layui.layer : top.layer,
        $ = layui.jquery,
        laydate = layui.laydate,
        laytpl = layui.laytpl,
        table = layui.table;
//列表
    var tableIns = table.render({
        elem: '#gitftList',
        url : '/${BasePath}/gift/queryGiftOrdePage',
        cellMinWidth : 95,
        page : true,
        height : "full-125",
        limit : 20,
        limits : [1,10,15,20,25],
        id : "productsListTable",
        cols : [[
            {type: "checkbox", fixed:"left", width:50},
            {field: 'money', title: '金额',width:80,align:'center',templet:function(d){return '<span class="layui-blue">'+d.money+'</span>'}},
            {field: 'playerid', title: '选手',width:90},
            {field: 'openid', title: '付款人',width:300},
            {field: 'activityid', title: '活动',width:400},
            {field: 'payState', title: '支付状态',templet:"#payState"},
            {field: 'payTime', title: '支付时间', templet:function(res){return replaceTime(res.payTime / 1000)}, width:200},
            {field: 'createTime', title: '创建时间', templet:function(res){return replaceTime(res.createTime / 1000)}, width:200},
            {field: 'orderNo', title: '订单编号',width:200},
        ]]
    ,skin: 'line'
    });

    //编辑商品
    function editgift(edit){
    	   window.location.href="/${BasePath}/gift/addGift?id="+edit.id;
    }
    $(".addGift").click(function(){
    	window.location.href="/${BasePath}/gift/addGift?id="+0;
    })

    //列表操作
    table.on('tool(gitftList)', function(obj){
        var layEvent = obj.event,
            data = obj.data;

        if(layEvent === 'edit'){ //编辑
        	editgift(data);
        } else if(layEvent === 'del'){ //删除
            layer.confirm('确定删除此礼物信息？',{icon:3, title:'提示信息'},function(index){
                 $.get("/${BasePath}/gift/deleteGift",{
                     id : data.id  //将需要删除的productsId作为参数传入
                 },function(data){
                    tableIns.reload();
                    layer.close(index);
                 })
            });
        } 
    });
    
    $(".refresh").click(function(){
    	window.location.reload();
    })

})
</script>
</body>
</html>